import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextArea;
import java.awt.*;




public class Rules {

	private JDialog rulesFrame;
	
	public Rules(){
		displayRules();
	}
	
	private void displayRules(){
		rulesFrame = new JDialog();
		rulesFrame.setVisible(true);
		rulesFrame.setBounds(100, 100, 703, 545);
		rulesFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
		JPanel ruleTitlePanel = new JPanel();
		rulesFrame.getContentPane().add(ruleTitlePanel, BorderLayout.NORTH);
		JLabel rulesTitle = new JLabel("Rules");
		rulesTitle.setFont(new Font("Serif", Font.PLAIN, 24)); 
		rulesTitle.setBounds(0, 0, 60, 60);
		ruleTitlePanel.add(rulesTitle);
		
		JPanel centerRules = new JPanel();
		rulesFrame.getContentPane().add(centerRules, BorderLayout.CENTER);
		centerRules.setLayout(null);
		
		JTextArea ruleText = new JTextArea();
		ruleText.setText("Rules of Nine Men's Morris\r\n\r\nThere are two players in the game. One player is red and the other is blue. Blue moves first.\r\n\r\nPlayers will take turns to play a piece of their own color on any unoccupied point until each player ahs placed all 9 of his/her pieces. Players will continue to alternate turns. Each turn the player moves one piece along a line to an adjacent point. \r\n\r\nDuring the piece placing and piece moving, when a player achieves a mill, that player immediately removes one of the opponent's pieces, that does not form a mill, from the board. If all of the opponents pieces form mills then the player is allowed to remove any piece. Once a piece is removed from the board, it remains out of play for the rest of the game. \r\n\r\nThe game is finished when a player loses by either having only two pieces left or being unable to make any moves.\r\n\r\nJava Applet Gameplay\r\n\r\nTo start a new game click the \"New Game\" button.\r\nTo see this rules page click the \"Rules\" button. \r\nTo see the leaderboard click the \"LeaderBoard\" button.\r\n\tThe leaderboard consists of the top five scores.\r\n\tThe scores are based on the fewest number of moves that took place during the game. (Lower is better)\r\nTo quit the game click the red \"X\" at the top right or click the \"Quit\" button.\r\n\r\nTo place pieces, click the piece with a mouse button and drag it to one of the black dots on the game board.\r\nThe piece will be placed on that point. \r\n\r\nThe counter at the bottom counts the number of moves in the game.");
		//ruleText.setText("This is a text box");
		ruleText.setBounds(25, 25, 635, 417);
		ruleText.setEditable(false);
		centerRules.add(ruleText);
	}
	
	/**
	 * sets visibility so that other windows can make it invisible
	 * @param t a boolean 
	 */
	public void setVisible(Boolean t){
		
		if(t == false)
			rulesFrame.setVisible(false);
		else 
			rulesFrame.setVisible(true);
		
		
	}
	
}
